package reproductores;

import java.io.IOException;

public class Amarok {
	public static void encolar(boolean solamenteEncolar, boolean unSoloTema, String url, String primerTema) {
		if (solamenteEncolar) {
			
			if (unSoloTema) {
				String[] commandLin = new String[]{"amarok", "-a" , url};
					
				try {
					//System.out.println(commandLin[0] + " " + commandLin[1] + " " + commandLin[2]);
					@SuppressWarnings("unused")
					Process procesoLin;
					procesoLin = Runtime.getRuntime().exec(commandLin, null, null);
				}
				catch (Exception e) {
					e.printStackTrace();
				}
			}
			else {
				String[] commandLin = {"bash", "-c", "amarok -a " + url};
				//System.out.println(commandLin[0] + " " + commandLin[1] + " " + commandLin[2]);
					
				try {
					Runtime.getRuntime().exec(commandLin);
				} catch (IOException e) {
					e.printStackTrace();
				} 
			}
		}
		else {
				
			if (unSoloTema) {
				
				String[] commandLin = new String[]{"amarok", "-p" , url};
				try {
					//System.out.println(commandLin[0] + " " + commandLin[1] + " " + commandLin[2]);
					@SuppressWarnings("unused")
					Process procesoLin;
					procesoLin = Runtime.getRuntime().exec(commandLin, null, null);
				}
				catch (Exception e) {
					e.printStackTrace();
				}
			}
			else {
				String[] mocp = {"bash", "-c", "amarok -a " + url};
				//System.out.println(mocp[0] + " " + mocp[1] + " " + mocp[2]);
				try {
					Runtime.getRuntime().exec(mocp);
				} catch (IOException e) {
					e.printStackTrace();
				} 
					
				mocp = new String[]{"bash", "-c", "amarok -p" + primerTema};
				//System.out.println(mocp[0] + " " + mocp[1] + " " + mocp[2]);
				try {
					Runtime.getRuntime().exec(mocp);
				} catch (IOException e) {
					e.printStackTrace();
				} 
			}
		}
	}
	
	public static void playPause() {
		String[] mocp = {"bash", "-c", "amarok -t"};
		try {
			Runtime.getRuntime().exec(mocp);
		} catch (IOException e) {
			e.printStackTrace();
		} 
	}
	
	public static void stop() {
		String[] mocp = {"bash", "-c", "amarok -s "};
		try {
			Runtime.getRuntime().exec(mocp);
		} catch (IOException e) {
			e.printStackTrace();
		} 
	}
}
